const Controller = require('egg').Controller

class RegController extends Controller {

  async postReg() {
    const {ctx} = this
    let body = ctx.request.body.data
    let regRes =await ctx.service.reg.postReg(body) 
    console.log(regRes);
    if(regRes) {
      if(regRes.code) {
        ctx.body = {
          code: 40000,
          data: '用户名重复'
        }
      }else{
        ctx.body = {
          code: 50000,
          data:{
            username:regRes.username,
            auth:regRes.auth,
            status:regRes.status,
            headImg:regRes.headImg,
            selfIntroduction:regRes.selfIntroduction,
          }
        }
      }
    }else {
      ctx.body = {
        code: 20000,
        data:'失败'
      }
    }
  }

}

module.exports = RegController